<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.java.service.*,java.util.*,com.java.model.UserSession,com.java.util.*"%>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<jsp:include page="common/header.jsp"></jsp:include>
<%
	UserSession usersession = (UserSession)session.getAttribute("user");
	String ent_id 			= (String)session.getAttribute("ent_id");
	
	String connGroup 	= "";
	String user_id 		= "";
	if(usersession!=null){
		connGroup 	= CmmUtil.nvl(usersession.getConnGroup(),"0");
		user_id 	= CmmUtil.nvl(usersession.getUser_id(),"");
	}
	String keyword_gb 	= CmmUtil.nvl(request.getParameter("search_gb"),"");
	String keyword 		= CmmUtil.nvl(request.getParameter("search_word"),"");
	String line_number	= CmmUtil.nvl(request.getParameter("line_number"),"10");
	
	System.out.println("keyword  " + keyword);
	
	String present_Year = String.valueOf(GregorianCalendar.getInstance().get(Calendar.YEAR));
	//GregorianCalendar에서 1월 return 값이 0이므로 Month에는  1을 더해주어야 함
	String present_Month = String.valueOf(GregorianCalendar.getInstance().get(Calendar.MONTH)+1); 
	String present_Date = String.valueOf(GregorianCalendar.getInstance().get(Calendar.DATE));
	
	if(present_Month.length() == 1){
		present_Month = "0" + present_Month; //01월,02월 ..... 09월
	}
	
	GregorianCalendar g = new GregorianCalendar();
	g.add(Calendar.MONTH, 0);
	
	String befor_Month = String.valueOf(g.get(Calendar.MONTH));
	
	if(befor_Month.length() == 1){
		befor_Month = "0" + befor_Month; //01월,02월 ..... 09월
	}
	
	if(present_Date.length() == 1){
		present_Date = "0" + present_Date; //01일,02일 ..... 09일
	}
	
	//start_dt,close_dt,selected_year,selected_month 의 값에 받아오는 인자가 없을 경우 default로 현재 시간을 Setting
	String start_dt 		= CmmUtil.nvl(request.getParameter("start_dt"),present_Year + befor_Month + present_Date);
	String close_dt 		= CmmUtil.nvl(request.getParameter("close_dt"),present_Year + present_Month + present_Date);
	
	//페이징 처리 Start
 	//페이지 표시정보 받기 혹은 검색입력창
 	String curr_page = request.getParameter("curr_page");
 	if (curr_page == null || curr_page.equals(""))
 		curr_page = "1";
 	String one_page = request.getParameter("line_number");
 	if (one_page == null || one_page.equals(""))
 		one_page = "10";
 	String one_group = request.getParameter("one_group");
 	if (one_group == null || one_group.equals(""))
 		one_group = "10";
 	
 	String total_count = CmmUtil.nvl(request.getParameter("total_count"),"0");
 	
 	//페이징 처리 End
 	
	HashMap map = new HashMap();
	HashMap map1 = null;
	ArrayList list = new ArrayList();
	CommonDaoService commonservice = new CommonDaoService("Com0102lp03Dao");
	map.put("connGroup",connGroup);
	map.put("user_id",user_id);
	map.put("ent_id",ent_id);
	map.put("keyword",keyword);
	map.put("search_combo",keyword_gb);
	map.put("start_dt",start_dt);
	map.put("close_dt",close_dt);
	map.put("page_row",line_number);
	map.put("total_row",total_count);
	map.put("page_no",curr_page);
	
	list = (ArrayList)commonservice.commonDaoMethod(map);
	
	System.out.println(list);
	if(list != null){
		if(list.size() > 0){
			total_count = (String)((HashMap)list.get(0)).get("total_row");
			System.out.println("total_count " + total_count);
		}
	}

	
%>
<script>
//검색
function search(){
	var frm = document.mainfrm;
	frm.curr_page.value ="1";
	frm.total_count.value=0;
	frm.action = "/jsp/com0102l_p03.jsp";
	frm.target="_self";
	frm.submit();
}

// 페이지 번호를 눌렸을때.
function go_page(page){
	var frm = document.mainfrm;
	frm.curr_page.value = page ;			
	frm.total_count.value = "<%=total_count%>";
	frm.search_word.value = "<%=keyword%>";
	frm.action = "/jsp/com0102l_p03.jsp";
	frm.target="_self";
	frm.submit();
}

//엑셀다운로드
function excel_down(){
	var frm = document.mainfrm;
	frm.action = "/jsp/com0102l_p03_excel.jsp";
	frm.target="_self";
	frm.method = "post";
	frm.submit();	
}
</script>
<body>
<table width="992" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td>
    <!--top -->
    <jsp:include page="common/top_menu.jsp"></jsp:include>
    <!-- //top -->
    <!-- contents area -->
<form name="mainfrm" method="post">
<input type="hidden" name="curr_page" value="<%=curr_page%>">
<input type="hidden" name="total_count" value="<%=total_count%>">
<input type="hidden" name="ent_id" value="<%=ent_id%>">

  <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="180" valign="top">
    	<jsp:include page="left/com0101l_p05.jsp"></jsp:include>
    </td>
    <td width="21" valign="top">&nbsp;</td>
    <td valign="top">
    	 <table width="790px"  border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td style="font-size:14px; color:#3b70a2; font-weight:bold; border-bottom:2px solid #c8c8c8; padding:0 0 5px 0;" align="left"><img src="/images/sub_icon1.jpg"  alt="" border="0">&nbsp;학습관리 - 학습결과</td>
             </tr>
        </table>
        <table width="790px"  border="0" cellpadding="0" cellspacing="0">
         <tr>
        	<td>
            	<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="main_table4">
                  <tr>
                    
                    <td class="table_th">학습자</td>
                    <td class="table_th">과정수</td>
                    <td class="table_th">수료</td>
                    <td class="table_th">미수료</td>
                    <td class="table_th">수료율</td>
                  </tr>
                  <tr>
                    
                    <td>40</td>
                    <td>12</td>
                    <td>32</td>
                    <td>8</td>
                    <td>92%</td>
                  </tr>
                </table>            
              </td>
        </tr>
        <tr>
            <td colspan="5" style="padding:5px 0 5px 0;" align="left"><img src="/images/line_member.gif"  alt="" border="0"></td>
        </tr>
        </table>
         <table width="790px" border="0" cellpadding="0" cellspacing="0" style="margin:20px 0 0 0">
           <tr>
             <td align="left">
             	<jsp:include page="common/selectbox_list.jsp"></jsp:include> 
             </td>
             
			 <td align="right">검색일자
				<input type="text" name="start_dt" id="start_dt" class="textbox" value="<%=start_dt %>"/>
				<script language=javascript>
				var basicCal = new calendar("FIELD:document.mainfrm.start_dt;FORMAT:2;DELIMITER:;");
    			basicCal.writeCalendar();
    			</script>
				~
				<input type="text" name="close_dt" id="close_dt" class="textbox" value="<%=close_dt %>"/>
				<script language=javascript>
				var basicCal = new calendar("FIELD:document.mainfrm.close_dt;FORMAT:2;DELIMITER:;");
    			basicCal.writeCalendar();
    			</script>
			 &nbsp;&nbsp;             
					<select name="search_gb">
						<option value="" <%if(keyword_gb.equals("")){%>selected<%}%>>검색조건</option>
                 		<option value="1" <%if(keyword_gb.equals("1")){%>selected<%}%>>성명</option>
                 		<option value="2" <%if(keyword_gb.equals("2")){%>selected<%}%>>과정명</option>
               		</select>
           		<input type="text" name="search_word" class="textbox" required="required" hname="검색어" />
                <a href="javascript:search()"><img src="/images/bt_search2.gif" align=absmiddle /></a>
             </td>
           </tr>
         </table>
         <table width="790px" border="0" cellspacing="0" class="bbs_property" summary="" style="font-size:11px; margin:13px 0 20px 0;">
            <caption></caption>
            <thead>
             <tr>
              <th>No</th>
              <th>과정</th>
              <th>성명</th>
              <th>기수</th>
              <th>진도</th>
              <th>과제</th>
              <th>최종</th>
              <th>총점</th>
              <th>수료</th>
             </tr>
            </thead>
            <tbody>
            <%for(int i=0; i<list.size(); i++){
            	map1 = (HashMap)list.get(i);
            %>
             <tr>
              <td scope="row" class="ranking"><%=map1.get("rownum") %></td>
              <td align="left"><%=map1.get("poi_nm")%></td>
              <td><%=map1.get("login_nm") %></td>
              <td><%=map1.get("kisu_info") %></td>
              <td><%=map1.get("final_prog_rate") %></td>
              <td><%=map1.get("rpt_point") %></td>
              <td><%=map1.get("final_eval_point") %></td>
              <td><%=map1.get("final_tot_point") %></td>
              <td><%=map1.get("fin_status") %></td>
             </tr>
             <%}%>
            </tbody>
            </table>
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
             <tr>
  
                <td align="center">
                	<table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="100%" align="left">
                        	<table width="100%" border="0" cellpadding="0" cellspacing="0" >
                                <tr>
                       			<!-- 페이징 -->
                       			<td align="center">
                       				<common:pagelistnew currPage="<%=curr_page%>" total="<%=total_count%>" onePage="<%=one_page%>" oneGroup="<%=one_group%>"/>
                       			</td>
                        		<!-- //페이징 -->
                                </tr>
                        	</table>                        
                        </td>
                      </tr>
                    </table>
           	  		<table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="84px" align="left">
                            <table border="0" cellpadding="0" cellspacing="0" >
                                <tr>
                                 
                                   <td align="left" style="padding:0 0 0 3px;"><a href="javascript:excel_down()"><img src="/images/btn_save_excel1.gif" align="absmiddle" /></a></td>
                              </tr>
                            </table>
                         </td>
                        </tr>
                    </table> 
               </td>
             </tr>
           </table>
    </td>
    </tr>
	</table>
</form>

    <jsp:include page="common/footer.jsp"></jsp:include>
	</td>
  </tr>
</table>
<iframe name='hide_src'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
</body>
</html>
